package com.xsy.android.compose.wandroid.ui.view.lce

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.xsy.android.compose.wandroid.logic.model.PlayError
import com.xsy.android.compose.wandroid.logic.model.PlayLoading
import com.xsy.android.compose.wandroid.logic.model.PlayState
import com.xsy.android.compose.wandroid.logic.model.PlaySuccess

/**
 *@author: xiaosy
 *时间: 2024/7/11
 *@Description: java类作用描述
 *@Version: 1.0
 **/
@Composable
fun <T> LcePage(
    modifier: Modifier = Modifier,
    playState: PlayState<T>,
    onErrorClick: () -> Unit,
    content: @Composable (data: T) -> Unit
) {
    when (playState) {
        is PlayLoading -> {
            LoadingContent()
        }

        is PlayError -> {
            ErrorContent(onErrorClick = onErrorClick)
        }

        is PlaySuccess<T> -> {
            content(playState.data)
        }
    }
}